
<style>

	.media{

		margin-bottom: 20px;
		border: 1px solid #efefef;
		clear: left;

	}
	.media .speci-lists{

		width: 100%;
		height: auto;
		border: 1px solid #ccc;
		position: relative;
		bottom: -10px;
		background: #fff;
		z-index: 9;
		padding: 5px 5px 0 5px;
		margin-bottom: 10px;

	}
	.media .speci-lists ul{

		width: auto;
		height: 100%;
		margin: 0;
		padding: 0;
		overflow: auto;
		white-space: nowrap;

	}
	.media .speci-lists ul li{

		width: 130px;
		height: auto;
		border-right: 1px dashed #ccc;
		display: inline-block;
		padding: 0 5px;

	}
	.media .speci-lists ul li:first-child{

		border-left: 1px dashed #ccc;

	}
	.media .speci-lists ul li .thumb{

		width: 100%;
		height: 80px;
		margin-bottom: 10px;

	}
	.media .speci-lists ul li .thumb img{

		width: 100%;
		height: 100%;

	}
	.media .speci-lists ul li .goods-spec{

		font-size: 12px;
		font-weight: bold;
		color: #888;

	}
	.media .speci-lists ul li .goods-spec strong{

		color: #448944;

	}
	.media .bar{

		width: 100%;
		height: 30px;
		background: #efefef;
		padding: 5px;
		margin-bottom: 5px;

	}
	.media .bar .btn{

		margin-left: 5px;

	}
	.status_bar{

		width: 100%;
		margin-bottom: 10px;
		background: #efefef;
		padding: 5px;
		margin-bottom: 5px;

	}
	.media-body{
		height: 64px;
	}
	.media-body{
		vertical-align: middle;
	}
	.speci-lists .triangle{
		display: block;
		border-color: transparent transparent #ccc;
		border-style: dashed dashed solid;
		border-width: 0 9px 9px;
		width: 0;
		height: 0;
		line-height: 0;
		position: absolute;
		left: 18px;
		top: -9px;
	}
	.triangle i{
		border-color: transparent transparent #fff;
		border-style: dashed dashed solid;
		border-width: 0 7px 7px;
		width: 0;
		height: 0;
		line-height: 0;
		position: absolute;
		left: -7px;
		top: 2px;
		z-index: 2;
	}
	.goods-spec.title{

		font-size: 12px !important;
		line-height: 16px;
		font-weight: 300 !important;
		white-space: normal;
		margin-bottom: 5px;


	}
</style>
<div class="status_bar" style="overflow: hidden">
	<div class="input-group pull-left" style="width: 40%;">
		<span class="input-group-addon radius-none">开始时间</span>
		<input class="form-control" value="<?php echo $start_time ?>" id="start-time" type="text" >
		<span class="input-group-addon" style="border-left: none;border-right: none;">结束时间</span>
		<input class="form-control radius-none" value="<?php echo $end_time ?>" id="end-time" type="text" >
	</div>
	<div class="input-group pull-left" style="width: 20%;margin-left: 5px;">
		<span class="input-group-addon radius-none">买家</span>
		<input class="form-control radius-none" value="<?php echo $member ?>" id="member" type="text" >
	</div>
	<div class="input-group pull-left" style="width: 25%; margin: 0 5px;">
		<span class="input-group-addon radius-none">订单号</span>
		<input class="form-control radius-none" value="<?php echo $number ?>" id="number" type="text" >
	</div>
	<button class="btn btn-default radius-none" id="search" type="button">搜索</button>
</div>
<?php if($data):?>
	<?php foreach($data as $k => $v):?>
	<div class="media">
		<div class="bar">
			<span>订单编号: <?php echo $v['number']?></span>
			<a class="btn btn-default btn-xs edit radius-none pull-right detail" data-id="<?php echo $v['id']?>" href="javascript:;">订单详情</a>
		</div>
		<div class="media-body">
			<div class="media-body">
				<div class="media-body">
					<div class="media-body text-center">
						订单金额
						<br />
						<strong class="red">
							&yen;<?php echo sprintf("%.2f", ($v['order_price_total'] / 100))?>
						</strong>
						<?php if($v['description_price']){echo '<br />('.$v['description_price'].')';}?>
						<br/>
						(含运费&yen;<?php echo sprintf("%.2f", ($v['freight'] / 100))?>)
						<?php if($v['description_freight']){echo '<br />('.$v['description_freight'].')';}?>
					</div>
					<div class="media-body text-center sh-info" data-container="body" data-title="收货信息" data-toggle="popover" data-placement="top" data-html="true" data-content="<strong>姓名:</strong> <?php echo $v['address_info']['recipient']?> <br /> <strong>联系电话:</strong> <?php echo $v['address_info']['mobile']?> <br /> <strong>收货地址:</strong>  <span style='font-size: 12px;'><?php echo $v['address_info']['province_name']?> <?php echo $v['address_info']['city_name']?> <?php echo $v['address_info']['county_name']?> <?php echo $v['address_info']['address']?></span> ">
						(买家)
						<br>
						<?php

							if ($v['member_info']['nicname']) {

								echo $v['member_info']['nicname'];

							} elseif($v['member_info']['username']) {

								echo $v['member_info']['username'];

							} elseif($v['member_info']['mobile']) {

								echo $v['member_info']['mobile'];

							}

						?>
					</div>
					<div class="media-body text-center">
						(下单时间)
						<br>
						<strong><?php echo $v['create_time']?></strong>
					</div>
					<div class="media-body text-center">

						<?php

							$state = [

								1 => '待支付',
								2 => '待发货',
								3 => '待收货',
								4 => '待评价',
								5 => '待退款',
								6 => '交易关闭',
								99 => '交易完成',

							];

						?>

						<?php echo $state[$v['status']]?>

					</div>
					<div class="media-body text-center" data-id="<?php echo $v['id']?>">


						<!--订单状态（1待支付，2:已支付待发货，3:已发货待收货,4:待评价,5:待退款, 6:交易关闭,7:删除订单, 99:交易完成-->
						<?php if($v['status'] == 1 && $v['is_delete'] == 1):?>
							<a class="btn btn-danger btn-xs radius-none cancel" style="margin: 2px 0;" href="javascript:;">取消订单</a>
							<br/>
							<a class="btn btn-warning btn-xs radius-none update-yf" style="margin: 2px 0;" href="javascript:;">修改运费</a>
							<br/>
							<a class="btn btn-success btn-xs radius-none update-price" style="margin: 2px 0;" href="javascript:;">修改价格</a>
						<?php elseif($v['status'] == 2 && $v['is_delete'] == 1):?>
							<a class="btn btn-warning btn-xs radius-none set-fh" style="margin: 2px 0;" href="javascript:;">设置发货</a>
						<?php elseif($v['status'] == 5 && $v['is_delete'] == 1):?>
							<a class="btn btn-warning btn-xs radius-none do-refund" style="margin: 2px 0;" href="javascript:;">处理退款</a>
						<?php elseif(($v['status'] ==6  || $v['status'] == 99) && $v['is_delete'] == 1):?>
							<a class="btn btn-warning btn-xs radius-none delete" style="margin: 2px 0;" href="javascript:;">删除订单</a>
						<?php endif;?>

					</div>
				</div>
			</div>
		</div>
		<div class="speci-lists">
			<div class="triangle">
				<i></i>
			</div>
			<ul>
				<?php foreach($v['order_extend'] as $val):?>
				<li>
					<div class="thumb">
						<img style="" src="<?php echo cutUrl($val['thumb'],150,80)?>" width="150" height="80" data-holder-rendered="true">
					</div>
					<div class="goods-spec title">
						<?php echo str_cut($val['title'],50)?>
					</div>
					<?php if($val['attr']):?>
						<div class="goods-spec">
							规格:
							<strong class="green" style="font-size: 10px">
								<?php foreach($val['attr'] as $value):?>
									<?php echo $value['name'].'&nbsp;'?>
								<?php endforeach;?>
							</strong>
						</div>
					<?php endif;?>
					<div class="goods-spec" data-price=<?php echo $val['price']?>>
						单价: <strong class="red">&yen;<?php echo sprintf("%.2f", ($val['_price'] / 100))?></strong>
					</div>
					<div class="goods-spec">
						运费: <strong class="red">&yen;<?php echo sprintf("%.2f", ($val['freight'] / 100))?></strong>
					</div>
					<div class="goods-spec">
						数量: <strong class="green"><?php echo $val['nums']?></strong>
					</div>
					<div class="goods-spec">
						总价: <strong class="red">&yen;<?php echo sprintf("%.2f", (($val['pay_total'] + $val['freight']) / 100))?></strong>
					</div>
				</li>
				<?php endforeach;?>
			</ul>
		</div>
	</div>
	<?php endforeach;?>
	<div role="group" data-total="<?php echo $total?>" data-page="<?php echo $page?>" data-nums="<?php echo $nums?>" data-src="<?php echo U('Admin/Order/Index/lists');?>"  class="btn-group" id="_pages"></div>
<?php else:?>
	<h1 style="font-size: 25px; font-weight: bold; text-align: center; margin-top: 50px;">没有找到符合要求的数据!</h1>
<?php endif;?>
<script>
	$(function(){
		var options = {

			'status': '<?php echo $status?>',
			'start_time': '<?php echo $start_time?>',
			'end_time': '<?php echo $end_time?>',
			'member': '<?php echo $member?>',
			'number': '<?php echo $number?>',
			'delete': '<?php echo $delete?>',

		}

		Admin.pages(options);
		//取消订单
		$('.cancel').unbind('click');
		$('.cancel').click(function(){

			var _this = $(this);

			var id = $(this)
							.parent()
							.data('id');

			layer.msg('确定要取消吗?', {
				time: 0 //不自动关闭
				,btn: ['确定', '关闭']
				,yes: function(index){

					layer.close(index);

					$.post('<?php echo U("Admin/Order/Index/cancel")?>',{'id':id},function(result){

						_this
								.parent()
								.html('<a class="btn btn-warning btn-xs radius-none delete" style="margin: 2px 0;" href="javascript:;">删除订单</a>')
								.prev()
								.text('交易关闭');

						showMessage(result.msg,result.code,'','',2000);

					});

				}
			});

		});
		//删除订单
		$('.delete').unbind('click');
		$('.delete').click(function(){

			var _this = $(this);

			var id = $(this)
							.parent()
							.data('id');

			layer.msg('确定要删除吗?', {
				time: 0 //不自动关闭
				,btn: ['确定', '关闭']
				,yes: function(index){

					layer.close(index);

					$.post('<?php echo U("Admin/Order/Index/delete")?>',{'id':id},function(result){

						if(result.code == 200)
							_this
									.parents('.media')
									.fadeOut(200,function(){

										$(this).remove();

									})

						showMessage(result.msg,result.code,'','',2000);

					});

				}
			});

		});

		//修改运费
		$('.update-yf').unbind('click');
		$('.update-yf').click(function(){

			var _this = $(this);

			var id = _this.parent().data('id');

			layer.prompt(function(val){



				if(isNaN(Number(val)) )  {

					alert('请输入正确的金额!');

					return false;

				}

				if(Number(val) < 0){

					alert('请输入正确的金额!');
					return false;

				}


				$.post('<?php echo U("Admin/Order/Index/setFreight")?>',{'id':id,'freight':val},function(result){

						var data = {

							'status'	: '<?php echo $status?>',
							'start_time': '<?php echo $start_time?>',
							'end_time'	: '<?php echo $end_time?>',
							'member'	: '<?php echo $member?>',
							'number'	: '<?php echo $number?>',
							'delete'	: '<?php echo $delete?>',
							'page' 		: "<?php echo $page?>"
						}

					showMessage(result.msg,result.code,"<?php echo U('Admin/Order/Index/lists');?>",data,2000);

				});


			});

		})

		//修改价格
		$('.update-price').unbind('click');
		$('.update-price').click(function(){

			var _this = $(this);

			var id = _this.parent().data('id');

			layer.prompt('请输入要修改的金额(元)',function(val){



				if(isNaN(Number(val)) )  {

					alert('请输入正确的金额!');

					return false;

				}

				if(Number(val) < 0.01){

					alert('请输入正确的金额!');
					return false;

				}


				$.post('<?php echo U("Admin/Order/Index/setPrice")?>',{'id':id,'price':val},function(result){

						var data = {

							'status'	: '<?php echo $status?>',
							'start_time': '<?php echo $start_time?>',
							'end_time'	: '<?php echo $end_time?>',
							'member'	: '<?php echo $member?>',
							'number'	: '<?php echo $number?>',
							'delete'	: '<?php echo $delete?>',
							'page' 		: "<?php echo $page?>"
						}

					showMessage(result.msg,result.code,"<?php echo U('Admin/Order/Index/lists');?>",data,2000);

				});


			});

		})

		$('#main-content').undelegate('.sh-info','click');
		$('#main-content').delegate('.sh-info','mouseover',function(){

			$(this).popover('show');

		});
		$('#main-content').undelegate('.sh-info','click');
		$('#main-content').delegate('.sh-info','mouseout',function(){

			$(this).popover('hide');

		});
		//时间选择
		var start = {
			elem: '#start-time',
			format: 'YYYY/MM/DD hh:mm:ss',
			min: '2000-00-00 00:00:00', //设定最小日期为当前日期
			max: '2099-06-16 23:59:59', //最大日期
			istime: true,
			istoday: false,
			choose: function(datas){
				end.min = datas; //开始日选好后，重置结束日的最小日期
				end.start = datas //将结束日的初始值设定为开始日
			}
		};
		var end = {
			elem: '#end-time',
			format: 'YYYY/MM/DD hh:mm:ss',
			min: '2000-00-00 00:00:00',
			max: '2099-06-16 23:59:59',
			istime: true,
			istoday: false,
			choose: function(datas){
				start.max = datas; //结束日选好后，重置开始日的最大日期
			}
		};
		laydate(start);
		laydate(end);


		//搜索
		$('#search').unbind('click');
		$('#search').click(function(){

			var data = {};

			data.start_time = $('#start-time').val();
			data.end_time = $('#end-time').val();
			data.member = $('#member').val();
			data.number = $('#number').val();
			data.delete = '<?php echo $delete?>';
			data.status = '<?php echo $status?>';

			if( !data.start_time && !data.end_time && !data.member && !data.number ) {

				showMessage('请至少填写一个!',300,'','',2000);

				return false;

			}

			showMessage('','',"<?php echo U('Admin/Order/Index/lists');?>",data,0);


		});

		//订单详情
		$('a.detail').unbind('click');
		$('a.detail').click(function(){

			var id = $(this).data('id');

			layer.load();

			$.post("<?php echo U('Admin/Order/Index/detail');?>",{"id":id},function(result){

				layer.closeAll();

				layer.open({
					type: 1,
					title: '订单详情',
					area: ['100%', '100%'],
					content: result,
				});

			})

		});

		//设置发货
		$('.set-fh').unbind('click');
		$('.set-fh').click(function(){

			var _this = $(this);

			var id = $(this).parent().data('id');

			layer.load();

			$.post("<?php echo U('Admin/Order/Index/setFh');?>",{"id":id},function(result){

				layer.closeAll();

				layer.open({
					type: 1,
					title: '发货设置',

					area: ['100%', '100%'],
					content: result,
					btn: ['立即发货', '关闭'],
					yes: function(idx,layero){

						var data = {};

						//获取发货快递
						data.express_s_id = $('select#sh-address option:selected',layero).val();
						data.express_s_name = $('select#sh-address option:selected',layero).text();
						//获取快递单号
						data.express_number = $('#express_number').val();
						//获取发货快递
						data.send_address = $('select#send_address option:selected',layero).text();
						data.send_address_id = $('select#send_address option:selected',layero).val();
						data.mobile = $('#mobile',layero).data('mobile');
						data.number = $('#number',layero).data('number');

						//获取用户电话号码


						data.id = $('#order_id').val();

						if( !data.express_number ) {

							showMessage('快递单号不能为空!',300,'','',2000);

							return false;

						}

						$.post('<?php echo U("Admin/Order/Index/setFh")?>',{'data':data},function(result){

							showMessage(result.msg,result.code,'','',2000);

							if ( result.code == 200 ){

								layer.close(idx);

								_this
										.parents('.media')
										.fadeOut(200,function(){

											$(this).remove();

										})

							}


						});




					}
				});

			})

		});
	});
</script>